package com.cyt.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.cyt.entity.XingWengXiZhi;
import com.cyt.util.DBManager;
// 新闻的专属页面 即article_list_more.jsp页面
public class XingWenZhuanShuDaoImpl {
	public List<XingWengXiZhi> getXingWengZhuanShuYe() {// 一般看sql语句有没有条件
		List<XingWengXiZhi> list = new ArrayList<XingWengXiZhi>();
		Statement st = null;
		ResultSet rs = null;
		// 1.建立连接
		Connection conn = DBManager.getConnection();
		// 2.创建Statement执行对象(用来执行sql语句)
		try {// try 正常执行
			st = conn.createStatement();
			// 3.sql语句
			String sql = "SELECT * FROM xingwengxizhi";
			// 4.执行sql语句,返回结果集
			rs = st.executeQuery(sql);
			// 5. 遍历结果集
			while (rs.next()) {
				int xingWengId = rs.getInt("xingWengId");
				String xWBiaoTi = rs.getString("xWBiaoTi");
				String xWengNeiRong = rs.getString("xWengNeiRong");
				String xuHao = rs.getString("xuHao");
				String renQi = rs.getString("renQi");
				int xWLeiXingId = rs.getInt("xWLeiXingId");
				String xWXiangXi = rs.getString("xWXiangXi");

				XingWengXiZhi xwZhuanShu = new XingWengXiZhi(xingWengId, xWBiaoTi, xWengNeiRong, xuHao, renQi, xWLeiXingId, xWXiangXi);// 创建用户对象
				list.add(xwZhuanShu);// 把user对象存入list中
			}
			return list;// 正常情况返回集合

		} catch (SQLException e) {// catch 异常执行
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;// 异常返回空
		} finally {
			DBManager.closeAll(conn, st, rs);
		}

	}
}
